﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

namespace HR.HrHelper
{
    public class JsonHelper
    {
        /// <summary>
        /// Json字符串转换为实体类对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="StrJson"></param>
        /// <returns></returns>
        public static T DeserializeJsonToObject<T>(string StrJson)where T : class
        {
            return JsonConvert.DeserializeObject<T>(StrJson) as T;
        }

        /// <summary>
        /// Json字符串转换为实体类对象集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="StrJson"></param>
        /// <returns></returns>
        public static List<T> DeserializeJsonToList<T>(string StrJson) where T : class
        {
            return JsonConvert.DeserializeObject<T>(StrJson) as List<T>;
        }
    }
}